package arena.base;

import gameframework.base.MoveStrategyKeyboard;

import java.awt.Point;
import java.awt.event.KeyEvent;

import arena.soldier.SoldierGame;

public class HeroMoveStrategy extends MoveStrategyKeyboard {
	SoldierGame hero;
	
	public HeroMoveStrategy(SoldierGame hero) {
		this.hero = hero;
	}

	@Override
	public void keyPressed(KeyEvent event) {
		
		int keycode = event.getKeyCode();			
		if (keycode != KeyEvent.VK_SPACE){
			super.keyPressed(event);
		}
		switch (keycode) {
		case KeyEvent.VK_SPACE:
			//Si c'est heroman, il n'a pas d'arme et ne peut donc pas frapper.
			if(!hero.getClass().toString().equals("class arena.soldier.HeroMan")){
				hero.setFighting(true);
			}
			break;
		case KeyEvent.VK_A:
			hero.createTower();
			break;
		}
	}
	
	@Override
	public void keyReleased(KeyEvent e) {
		int keycode = e.getKeyCode();
		if (keycode != KeyEvent.VK_SPACE){		
			getSpeedVector().setDirection(new Point(0, 0));
		}
	}
	
	public void setHero(SoldierGame hero){
		this.hero = hero;
	}
}
